Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update(IText): Add method _enterEditing #10190

Merged
merged 8 commits into from
Oct 8, 2024
Merged

Conversation

zhe-he
Copy link
Contributor

@zhe-he zhe-he commented Sep 29, 2024

Add method _enterEditing to prevent triggering text:editing:entered.

#10187

Copy link

codesandbox bot commented Sep 29, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

/**
* runs the actual logic that enter from editing state, see {@link enterEditing}
*/
protected _enterEditing() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if is protected you can't really call it by yourself. This should stay public and have a different name.
Maybe enterEditingImpl ( as for implementation ) is better than the underscore prefix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that other internal methods that do not trigger the fire event are all prefixed with an underscore, such as
_discardActiveObject/discardActiveObject and _exitEditing/exitEditing, which is why I named it this way.
I should also change the _exitEditing method to public.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To unify, I changed the method name _exitEditing to exitEditingImpl.

@asturur
Copy link
Member

asturur commented Sep 30, 2024

Also please divide eventual tests for enterEditing for the 2 respective methods, under JEST.
If you don't know how to do that i can provide guidance.

@zhe-he
Copy link
Contributor Author

zhe-he commented Oct 8, 2024

Test cases have been added, but I cannot test them locally. The reasons are as follows:
When I executed ./node_modules/.bin/jest ./src/shapes/IText/ITextBehavior.test.ts before adding the test cases, the previous test cases reported errors. This issue may need your attention.

@asturur
Copy link
Member

asturur commented Oct 8, 2024

Hopefully i didn't break anything.
I left _exitEditing to avoid breaking changes and introduced anyway exitEditingImpl

@asturur
Copy link
Member

asturur commented Oct 8, 2024

Test cases have been added, but I cannot test them locally. The reasons are as follows: When I executed ./node_modules/.bin/jest ./src/shapes/IText/ITextBehavior.test.ts before adding the test cases, the previous test cases reported errors. This issue may need your attention.

There was an unrestored mock in the previous tests

@asturur asturur merged commit 3a9b093 into fabricjs:master Oct 8, 2024
18 of 20 checks passed
@zhe-he
Copy link
Contributor Author

zhe-he commented Oct 9, 2024

I looked at the v5 code and found that the _exitEditing method was not present in the previous version; it was added in v6. Therefore, removing it will not affect the old version. Additionally, in v6, it is marked as a private method, and if used externally, TypeScript will issue a warning unless used as shown below. This is why I removed it.

image image

@asturur
Copy link
Member

asturur commented Oct 9, 2024

Yes but you never know what people do.
I can't say 'typescript is warning you so is not a breaking change' if someone override that method in a subclass could have troubles.

@asturur
Copy link
Member

asturur commented Oct 9, 2024

Easier to keep and remove later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants